﻿<Window x:Class="NetwerkScanner.MainWindow" ResizeMode="CanMinimize" xmlns:sys="clr-namespace:System;assembly=mscorlib"  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:NetwerkScanner" Title="Netwerk Scanner" Height="550" Width="807" xmlns:chartingToolkit="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit" Icon="/NetwerkScanner;component/Resources/icon.png">

    <Window.Resources>
        <ResourceDictionary Source="Resources.xaml" />
    </Window.Resources>
    <TabControl Name="tabControl1">
        <TabItem Header="Overzicht" Name="tabItem1">
            <Grid>
                <TreeView Width="341" Name="_myTreeView" Margin="6,6,0,12" HorizontalAlignment="Left" Height="446" ItemsSource="{Binding}">
                    <!-- Double click event om een tabblad te openen als er op de treeview item geklikt wordt -->
                    <TreeView.ItemContainerStyle>
                        <Style TargetType="{x:Type TreeViewItem}">
                            <EventSetter Event="MouseDoubleClick" Handler="OnItemMouseDoubleClick" />
                        </Style>
                    </TreeView.ItemContainerStyle>
                    <TreeView.Resources>
                        <!-- Verbergt de blauwe selectie kleur rond de treeviewitem -->
                        <SolidColorBrush Color="Transparent" x:Key="{x:Static SystemColors.HighlightBrushKey}"/>
                        <!-- Maakt de access points en hosts node aan onder het ssid -->
                        <HierarchicalDataTemplate DataType="{x:Type local:FolderNode}" ItemsSource="{Binding Items}">
                            <Border Padding="4" BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10" Background="{StaticResource TreeViewItemBackground}" >
                                <TextBlock>
                                    <TextBlock.Text>
                                        <MultiBinding StringFormat="{}{0} ({1})">
                                            <Binding Path="Name"/>
                                            <Binding Path="Items.Count"/>
                                        </MultiBinding>
                                    </TextBlock.Text>
                                </TextBlock>
                            </Border>
                        </HierarchicalDataTemplate>
                        <!-- Maakt de ssid nodes aan -->
                        <HierarchicalDataTemplate DataType="{x:Type local:ExtendedServiceSet}" >
                            <HierarchicalDataTemplate.ItemsSource>
                                <MultiBinding>
                                    <MultiBinding.Converter>
                                        <local:MultiCollectionConverter />
                                    </MultiBinding.Converter>
                                    <Binding Path="BasicServiceSets" />
                                    <Binding Path="Hosts" />
                                </MultiBinding>
                            </HierarchicalDataTemplate.ItemsSource>
                            <Border  BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10" Background="{StaticResource TreeViewItemBackground}" >
                                <Expander Header="{Binding SSID}" IsTabStop="False" HorizontalAlignment="Left" IsEnabled="True" ExpandDirection="Down">
                                    <StackPanel Margin="5,5,5,5">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=BasicServiceSets.Count}"/>
                                            <TextBlock Text=" Access Points"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding Path=Hosts.Count}"/>
                                            <TextBlock Text=" Hosts"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="{Binding RSSI}"/>
                                            <TextBlock Text=" RSSI"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Expander>
                            </Border>
                        </HierarchicalDataTemplate>
                        <!-- Maakt de access point nodes aan -->
                        <DataTemplate DataType="{x:Type local:BasicServiceSet}" >
                            <Border BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10" Background="{StaticResource TreeViewItemBackground}" >
                                <Expander Header="{Binding MACAddress}" IsTabStop="False" HorizontalAlignment="Left" IsEnabled="True" ExpandDirection="Down">
                                    <StackPanel Margin="5,5,5,5">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="RSSI: "/>
                                            <TextBlock Text="{Binding RSSI}"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Eerst gezien: "/>
                                            <TextBlock Text="{Binding Path=EerstGezien, StringFormat={}\{0:HH:mm:ss\}}"/>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Laatst gezien: "/>
                                            <TextBlock Text="{Binding Path=LastUpdate, StringFormat={}\{0:HH:mm:ss\}}"/>
                                        </StackPanel>
                                    </StackPanel>
                                </Expander>
                            </Border>
                        </DataTemplate>
                        <!-- Maakt de host nodes aan -->
                        <DataTemplate DataType="{x:Type local:Host}">
                            <Border BorderBrush="AliceBlue" BorderThickness="1" CornerRadius="10" Background="{StaticResource TreeViewItemBackground}" >
                                <Expander Header="{Binding IPAdres}" IsTabStop="False" HorizontalAlignment="Left" IsEnabled="True" ExpandDirection="Down">
                                    <StackPanel Margin="5,5,5,5">
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="Latency: "></TextBlock>
                                            <TextBlock Text="{Binding Ping}"></TextBlock>
                                            <TextBlock Text="ms"></TextBlock>
                                        </StackPanel>
                                        <StackPanel Orientation="Horizontal">
                                            <TextBlock Text="MAC: "></TextBlock>
                                            <TextBlock Text="{Binding MACAddress}"></TextBlock>
                                        </StackPanel>
                                    </StackPanel>
                                </Expander>
                            </Border>
                        </DataTemplate>
                    </TreeView.Resources>
                </TreeView>
                <!-- Achtergrond afbeelding van de radar -->
                <Rectangle Height="400" Width="400" Margin="375,6,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                    <Rectangle.Fill>
                        <ImageBrush ImageSource="Resources/radarbg.png"></ImageBrush>
                    </Rectangle.Fill>
                </Rectangle>
                <!-- Draaiend gedeelte van de radar -->
                <Rectangle Height="400" Width="400" Margin="375,6,0,0" VerticalAlignment="Top" RenderTransformOrigin="0.5,0.5">
                    <Rectangle.RenderTransform>
                        <RotateTransform x:Name="rectangleRotate"/>
                    </Rectangle.RenderTransform>
                    <Rectangle.Fill>
                        <ImageBrush ImageSource="Resources/radar.png"></ImageBrush>
                    </Rectangle.Fill>
                    <Rectangle.Triggers>
                        <EventTrigger RoutedEvent="Canvas.Loaded">
                            <BeginStoryboard>
                                <Storyboard>
                                    <DoubleAnimation Storyboard.TargetName="rectangleRotate" Storyboard.TargetProperty="Angle" From="360.0" To="0.0" Duration="0:0:20" RepeatBehavior="Forever"/>
                                </Storyboard>
                            </BeginStoryboard>
                        </EventTrigger>
                    </Rectangle.Triggers>
                </Rectangle>
                <!-- Canvas om de netwerken op te tekenen -->
                <Canvas Height="400" Name="radarCanvas" VerticalAlignment="Top" Width="400" Margin="375,6,0,0">
                </Canvas>
                <!-- Controls om de schaal van de rader te veranderen -->
                <StackPanel Orientation="Horizontal" Margin="375,411,0,0" Height="34" Width="400">
                    <Label Content="RSSI" Name="label2" />
                    <local:NumericEntryControl HorizontalAlignment="Left" x:Name="van"  Height="30" Width="120" Value="-40" />
                    <Label Content="Tot" HorizontalAlignment="Right" Name="label3" />
                    <local:NumericEntryControl HorizontalAlignment="Left" x:Name="tot" Height="30" Width="120" Value="-70"  />
                    <Button Content="Reset" Height="30" Name="button1" Width="86" Margin="10,0" Click="ResetClick" />
                </StackPanel>
            </Grid>
        </TabItem>
    </TabControl>
</Window>
